using System;
using System.Drawing;
using System.Windows.Forms;
namespace PopLava.Tools
{
    /// <summary>
    /// Allows the user to click anywhere on the form to drag it
    /// </summary>
    public class ResizingControls
    {
        private Control g_oControl;
        private bool g_bIsSizing;
        /// <summary>
        /// Pass in the control to be resized
        /// </summary>
        public ResizingControls(Control control)
        {
            this.g_oControl = control;
        }
        public void GrabControl()
        {
            g_bIsSizing = true;
        }
        /// <summary>
        /// While the mouse has the left mouse button down, we will resize the control.
        /// </summary>
        public void ResizeControl(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:
                    if (g_bIsSizing)
                    {
                        this.g_oControl.Width = e.X;
                        this.g_oControl.Height = e.Y;
                    }
                    break;
                default:
                    {
                        break;
                    }
            }
        }
        public void ReleaseControl(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:
                    {
                        g_bIsSizing = false;
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
        }
    }
}
